| Blink WPT Bot | 76b44c0 | 2020-08-03 14:07:00 | [diff] [blame] | 1 | <!doctype html> | 
|  | 2 | <meta charset=utf-8> | 
|  | 3 | <title>RTCPeerConnection.prototype.iceGatheringState</title> | 
|  | 4 | <script src="/resources/testharness.js"></script> | 
|  | 5 | <script src="/resources/testharnessreport.js"></script> | 
|  | 6 | <script src="RTCPeerConnection-helper.js"></script> | 
|  | 7 | <script> | 
|  | 8 | 'use strict'; | 
|  | 9 |  | 
|  | 10 | promise_test(async t => { | 
|  | 11 | const pc1 = new RTCPeerConnection(); | 
|  | 12 | t.add_cleanup(() => pc1.close()); | 
|  | 13 | const pc2 = new RTCPeerConnection(); | 
|  | 14 | t.add_cleanup(() => pc2.close()); | 
| youennf | 6c623dc | 2021-09-14 06:59:41 | [diff] [blame] | 15 | pc1.addTransceiver('audio', { direction: 'recvonly' }); | 
| Blink WPT Bot | 76b44c0 | 2020-08-03 14:07:00 | [diff] [blame] | 16 | await initialOfferAnswerWithIceGatheringStateTransitions( | 
| youennf | 6c623dc | 2021-09-14 06:59:41 | [diff] [blame] | 17 | pc1, pc2); | 
| Blink WPT Bot | 76b44c0 | 2020-08-03 14:07:00 | [diff] [blame] | 18 | await pc1.setLocalDescription(await pc1.createOffer({iceRestart: true})); | 
|  | 19 | await iceGatheringStateTransitions(pc1, 'gathering', 'complete'); | 
|  | 20 | expectNoMoreGatheringStateChanges(t, pc1); | 
|  | 21 | await pc1.setLocalDescription({type: 'rollback'}); | 
|  | 22 | await new Promise(r => t.step_timeout(r, 1000)); | 
|  | 23 | }, 'rolling back an ICE restart when gathering is complete should not result in iceGatheringState changes'); | 
|  | 24 |  | 
|  | 25 | promise_test(async t => { | 
|  | 26 | const pc = new RTCPeerConnection(); | 
|  | 27 | t.add_cleanup(() => pc.close()); | 
| youennf | 6c623dc | 2021-09-14 06:59:41 | [diff] [blame] | 28 | pc.addTransceiver('audio', { direction: 'recvonly' }); | 
| Blink WPT Bot | 76b44c0 | 2020-08-03 14:07:00 | [diff] [blame] | 29 | await pc.setLocalDescription( | 
| youennf | 6c623dc | 2021-09-14 06:59:41 | [diff] [blame] | 30 | await pc.createOffer()); | 
| Blink WPT Bot | 76b44c0 | 2020-08-03 14:07:00 | [diff] [blame] | 31 | await iceGatheringStateTransitions(pc, 'gathering', 'complete'); | 
|  | 32 | await pc.setLocalDescription({type: 'rollback'}); | 
|  | 33 | await iceGatheringStateTransitions(pc, 'new'); | 
|  | 34 | }, 'setLocalDescription(rollback) of original offer should cause iceGatheringState to reach "new" when starting in "complete"'); | 
|  | 35 |  | 
|  | 36 | promise_test(async t => { | 
|  | 37 | const pc = new RTCPeerConnection(); | 
|  | 38 | t.add_cleanup(() => pc.close()); | 
| youennf | 6c623dc | 2021-09-14 06:59:41 | [diff] [blame] | 39 | pc.addTransceiver('audio', { direction: 'recvonly' }); | 
| Blink WPT Bot | 76b44c0 | 2020-08-03 14:07:00 | [diff] [blame] | 40 | await pc.setLocalDescription( | 
| youennf | 6c623dc | 2021-09-14 06:59:41 | [diff] [blame] | 41 | await pc.createOffer()); | 
| Blink WPT Bot | 76b44c0 | 2020-08-03 14:07:00 | [diff] [blame] | 42 | await iceGatheringStateTransitions(pc, 'gathering'); | 
|  | 43 | await pc.setLocalDescription({type: 'rollback'}); | 
|  | 44 | // We might go directly to 'new', or we might go to 'complete' first, | 
|  | 45 | // depending on timing. Allow either. | 
|  | 46 | const results = await Promise.allSettled([ | 
|  | 47 | iceGatheringStateTransitions(pc, 'new'), | 
|  | 48 | iceGatheringStateTransitions(pc, 'complete', 'new')]); | 
|  | 49 | assert_true(results.some(result => result.status == 'fulfilled'), | 
|  | 50 | 'ICE gathering state should go back to "new", possibly through "complete"'); | 
|  | 51 | }, 'setLocalDescription(rollback) of original offer should cause iceGatheringState to reach "new" when starting in "gathering"'); | 
|  | 52 |  | 
|  | 53 | </script> |